#include <bits/stdc++.h>
using namespace std;
#define int long long

const int N = 3e5+9;
vector<int> v;

int bin(int x){
    return lower_bound(v.begin(),v.end(),x) - v.begin() + 1;
}
int n,q;
int a[N];

struct node{
    int a; int b;
}add[N], que[N];

signed main(){
    cin >> n >> q;
    for ( int i=1; i<=n; i++ ){
        int ii,xx; cin >> ii >> xx;
        add[i] = {ii,xx};
        v.push_back(ii);
    }

    for ( int i=1; i<=q; i++ ){
        int ll,rr; cin >> ll >> rr;
        que[i] = {ll,rr};
        v.push_back(ll); v.push_back(rr);
    }

    sort(v.begin(), v.end());
    v.erase( unique(v.begin(), v.end()), v.end() );

    for ( int i=1; i<=n; i++ ){
        int ii = bin(add[i].a);
        int xx = add[i].b;
        a[ii] += xx;
    }

    for ( int i=1; i<=v.size(); i++ ) a[i] += a[i-1];

    for ( int i=1; i<=q; i++ ){
        int ll = bin(que[i].a);
        int rr = bin(que[i].b);
        cout  << a[rr] - a[ll-1] << '\n';
    }

    return 0;
}